﻿using Commom;
using EF_Brave.Domain.bll;
using EF_Brave.Domain.bll_i;
using EF_Brave.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EF_Brave.Web.Controllers
{
    public class AccountController : Controller
    {
        //
        // GET: /Account/
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Login()
        {
            ViewBag.LoginStatus = "登录前";
            return View();
        }

        [HttpPost]
        public ActionResult Login(FormCollection form)
        {
            string uname = form["uname"];
            string pwd = form["pwd"];

            //使用正常方式调用实现接口的方法
            //UserManage manage = new UserManage();
            //Sys_User user = manage.UserLogin(uname, pwd);
            //List<Sys_User> users = manage.GetAll();

            Sys_User user = new UserManageBLL().UserLogin(uname, pwd);
            if (user != null && user.Id != 0)
            {
                ViewBag.LoginStatus = "登陆成功,用户真名:" + user.UserTrueName;
            }
            else
            {
                ViewBag.LoginStatus = "登陆失败";
            }
            //使用autofac依赖注入的方式实现的接口方法

            //Sys_User user2 = new UserManageBLL().UserLoginAsync(uname, pwd);//异步方式调用
            return View();
        }

        public ActionResult Register()
        {
            return View();
        }
    }
}